﻿using UnityEngine;
using System.Collections;

public class FX_rotate : MonoBehaviour {

	public bool bAlignWorld = false;

	public Vector3 vRotationValue = new Vector3 (0, 0, 0);

	public float fTimeScale = 1.0f;

	Quaternion vOriginalRotation;
	
	float timer = 0;
	
	[SerializeField]
	AnimationCurve curveX;
	[SerializeField]
	AnimationCurve curveY;
	[SerializeField]
	AnimationCurve curveZ;

	void Start(){
		vOriginalRotation = transform.rotation;
		}
	void Update ()
	{

		Vector3 rotation;
		rotation.x = curveX.Evaluate(timer*fTimeScale)* vRotationValue.x;
		rotation.y = curveY.Evaluate(timer*fTimeScale)* vRotationValue.y;
		rotation.z = curveZ.Evaluate(timer*fTimeScale)* vRotationValue.z;

		if (bAlignWorld) {
			transform.rotation = Quaternion.Euler (rotation);
				} else {
			transform.rotation = Quaternion.Euler (rotation)* vOriginalRotation;
				}
		//transform.Rotate(vRotationValue.x,vRotationValue.y*Time.deltaTime*rotation.y,vRotationValue.z,(bWorldSpace ? Space.World : Space.Self));
		
		timer += Time.deltaTime;
	}
}
